#ifndef _sh8601z_h_
#define _sh8601z_h_

#include "main.h"

#define         SH8601Z_WIDTH           (368 - 1)
#define         SH8601Z_HIGHT           (448 - 1)
#define         SH8601Z_SEND_LINES      (44)//这个参数最好是 SH8601Z_HIGHT 的公约数
#define         SH8601Z_SEND_QUEUES     (20)
#define         SH8601Z_SEND_MAX_SIZE   ((SH8601Z_WIDTH + 1) * SH8601Z_SEND_LINES * 2)

#define         SH8601Z_MOSI_PIN        (GPIO_NUM_14)
#define         SH8601Z_MISO_PIN        (GPIO_NUM_13)
#define         SH8601Z_MCLK_PIN        (GPIO_NUM_12)
#define         SH8601Z_MNSS_PIN        (GPIO_NUM_11)

#define         SH8601Z_QSPI_DAT0       (SH8601Z_MOSI_PIN)
#define         SH8601Z_QSPI_DAT1       (SH8601Z_MISO_PIN)
#define         SH8601Z_QSPI_DAT2       (GPIO_NUM_10)
#define         SH8601Z_QSPI_DAT3       (GPIO_NUM_9)
#define         SH8601Z_QSPI_SCK        (SH8601Z_MCLK_PIN)
#define         SH8601Z_QSPI_NSS        (SH8601Z_MNSS_PIN)

#define         SH8601Z_RS_PIN          (GPIO_NUM_47)
#define         SH8601Z_DC_PIN          (GPIO_NUM_21)
#define         SH8601Z_TE_PIN          (GPIO_NUM_48)
#define         SH8601Z_PWR_PIN         (GPIO_NUM_42)

#define         SH8601Z_COLOR_RED       (0xf800)
#define         SH8601Z_COLOR_GREEN     (0x07e0)
#define         SH8601Z_COLOR_BLUE      (0x001f)
#define         SH8601Z_COLOR_WHITE     (0xffff)
#define         SH8601Z_COLOR_BLACK     (0x0000)
#define         SH8601Z_COLOR_YELLOW    (0xffe0)
#define         SH8601Z_COLOR_PURPLE    (0x8010)

void sh8601z_set_bl(uint8_t level);
void sh8601z_set_rs(uint8_t level);
void sh8601z_set_dc(uint8_t level);
void sh8601z_set_cs(uint8_t level);
uint8_t sh8601z_get_te(void);
void sh8601z_delay(uint32_t time);
void sh8601z_config(void);
void qspi_1l_write_command_and_data(uint8_t command, const uint8_t *buf, uint16_t buf_len);
void qspi_4l_write_command_and_data(uint8_t command, const uint8_t *buf,uint16_t buf_len);
void SH8601Z_Init(void);

void SH8601Z_No_Operation(void);
void SH8601Z_Software_Reset(void);
uint32_t SH8601Z_Read_Display_Identification_Information(void);
uint8_t SH8601Z_Read_Number_of_the_Errors_on_DSI(void);
uint8_t SH8601Z_Read_Display_Power_Mode(void);
uint8_t SH8601Z_Read_Display_MADCTL(void);
uint8_t SH8601Z_Read_Display_Pixel_Format(void);
uint8_t SH8601Z_Read_Display_Image_Mode(void);
uint8_t SH8601Z_Read_Display_Signal_Mode(void);
uint8_t SH8601Z_Read_Display_Self_Diagnostic_Result(void);
void SH8601Z_Sleep_In(void);
void SH8601Z_Sleep_Out(void);
void SH8601Z_Partial_Display_Mode_On(void);
void SH8601Z_Normal_Display_Mode_On(void);
void SH8601Z_Display_Inversion_Off(void);
void SH8601Z_Display_Inversion_On(void);
void SH8601Z_All_Pixel_Off(void);
void SH8601Z_All_Pixel_On(void);
void SH8601Z_Display_Off(void);
void SH8601Z_Display_On(void);
void SH8601Z_Column_Address_Set(uint16_t sc,uint16_t ec);
void SH8601Z_Page_Address_Set(uint16_t sp, uint16_t ep);
void SH8601Z_Memory_Write_Start(uint8_t *buf,uint16_t buf_len);
void SH8601Z_Partial_Area_Row_Set(uint16_t psp, uint16_t pep);
void SH8601Z_Partial_Area_Column_Set(uint16_t psc,uint16_t pec);
void SH8601Z_Tearing_Effect_Off(void);
void SH8601Z_Tearing_Effect_On(uint8_t tem);
void SH8601Z_Memory_Data_Access_Control(uint8_t byte);
void SH8601Z_Idle_Mode_Off(void);
void SH8601Z_Idle_Mode_On(void);
void SH8601Z_Control_Interface_Pixel_Format(uint8_t byte);
void SH8601Z_Memory_Write_Continue(uint8_t *buf,uint16_t buf_len);
void SH8601Z_Set_Tear_ScanLine(uint16_t te_scanline);
uint16_t SH8601Z_Read_Scan_Line_Number(void);
void SH8601Z_SPI_Read_Off(void);
void SH8601Z_SPI_Read_On(void);
void SH8601Z_AOD_Mode_Off(void);
void SH8601Z_AOD_Mode_On(void);
void SH8601Z_Write_Display_Brightness_Value_in_AOD_Mode(uint16_t aod_dbv);
uint16_t SH8601Z_Read_Display_Brightness_Value_in_AOD_Mode(void);
void SH8601Z_Deep_Standby_Control(uint8_t dstb);
void SH8601Z_Write_Display_Brightness_Value(uint16_t dbv);
uint16_t SH8601Z_Read_Display_Brightness_Value(void);
void SH8601Z_Write_CTRL_Display_1(uint8_t byte);
uint8_t SH8601Z_Read_CTRL_Display_1(void);
void SH8601Z_Write_CTRL_Display_2(uint8_t byte);
uint8_t SH8601Z_Read_CTRL_Display_2(void);
void SH8601Z_Write_CE(uint8_t byte);
uint8_t SH8601Z_Read_CE(void);
void SH8601Z_Write_Display_Brightness_Value_in_HBM_Mode(uint16_t hbm_dbv);
uint16_t SH8601Z_Read_Display_Brightness_Value_in_HBM_Mode(void);
void SH8601Z_HBM_Control(uint8_t byte);
void SH8601Z_Pixel_Format_Option(uint8_t byte);
void SH8601Z_Read_DDB_Start(uint8_t *ddb);
void SH8601Z_Read_DDB_Continue(uint8_t *ddbn);
uint8_t SH8601Z_Read_First_Checksum(void);
uint8_t SH8601Z_Read_Continue_Checksum(void);
void SH8601Z_SPI_Mode_Control(uint8_t byte);
uint32_t SH8601Z_Read_ID(void);
void SH8601Z_Fill(uint16_t xs,uint16_t ys,uint16_t xe,uint16_t ye,uint16_t color);
void SH8601Z_Flush_Old(uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye, void *p_color);
void SH8601Z_Point(uint16_t x,uint16_t y,uint16_t color);
void SH8601Z_Clear(uint16_t color);
void SH8601Z_Flush(uint16_t xs,uint16_t ys,uint16_t xe,uint16_t ye,void *p);
#endif
